<!DOCTYPE html>

<html>

<head>
    <meta charset="utf-8">
    <title>辖区医疗卫生机构统计表</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
    <link rel="stylesheet" href="../../layuiadmin/layui/css/layui.css" media="all">
    <link rel="stylesheet" href="../../layuiadmin/style/admin.css" media="all">
    <style type="text/css">
        .laytable-cell-radio.layui-table-cell {
            padding: 0 5px 0 15px;
        }
        
        .laytable-cell-radio span {
            display: none;
        }
        
        .laytable-cell-radio .layui-form-radio {
            padding-right: 0;
            margin: 0;
        }
    </style>
</head>

<body>
    <!-- <div class="layui-form" style="margin-left:20px;margin-top:15px;margin-bottom:-20px">
        <div class="layui-form-item">
            <label class="layui-form-label">统计日期</label>
            <div class="layui-inline" style="width: 200px;">
                <input type="text" class="layui-input" id="datetime" placeholder="请选择日期">
            </div>
            <button class="layui-btn layui-btn-normal" data-type="reload" id="serch" style="width:120px;"><i class="layui-icon">&#xe615;</i>按重量统计</button>
            <button class="layui-btn layui-btn-normal" data-type="reload" id="serchcollect" style="width:130px;"><i class="layui-icon">&#xe615;</i>按收集量统计</button>
        </div>
    </div> -->
    <h3>2017年医疗废物收集总量</h3>
    <table id="demo" lay-filter="test"></table>
    <h3>2017年医院各类废物收集情况</h3>
    <table id="demo1" lay-filter="test"></table>
    <h3>2017年基层医疗机构各类废物收集情况</h3>
    <table id="demo2" lay-filter="test"></table>
    <script src="../../layuiadmin/layui/layui.js"></script>
    <script src="../../layuiadmin/layui/jquery-3.3.1.min.js"></script>
    <script>
        layui.config({
            base: '../../layuiadmin/' //静态资源所在路径
        }).extend({
            index: 'lib/index' //主入口模块
        }).use(['index']);
        // layui.use('laydate', function() {
        //     var laydate = layui.laydate;

        //     //执行一个laydate实例
        //     laydate.render({
        //         elem: '#datetime', //指定元素
        //         range: true,
        //         max: 0,
        //         theme: '#1E9FFF'
        //     });
        // });
        var json = [{
            to: 28327,
            ho: 22300,
            ba: 4599
        }]
        var json1 = [{
            to: 20920,
            ho: 1307,
            ba: 66,
            ca: 7,
            da: 0
        }]
        var json2 = [{
            to: 4482,
            ho: 99,
            ba: 18,
            ca: 1,
            da: 0
        }]
        layui.use('table', function() {
            var table = layui.table;
            var $ = layui.$;

            table.render({
                elem: '#demo1',
                height: '150px',
                data: json1,
                cols: [
                    [ //表头
                        {
                            field: 'to',
                            title: '医院感染性医疗废物(吨)',
                            width: "20%"
                        }, {
                            field: 'ho',
                            title: '医院损伤性医疗废物(吨)',
                            width: "20%"
                        }, {
                            field: 'ba',
                            title: '医院病理性医疗废物(吨)',
                            width: "20%"

                        }, {
                            field: 'ca',
                            title: '医院药物性医疗废物(吨)',
                            width: "20%"

                        }, {
                            field: 'da',
                            title: '医院化学性医疗废物(吨)',
                            width: "20%"

                        }


                    ]
                ],
                skin: 'row', //表格风格				
                even: true,

            });
            $("table thead tr").css({
                "background": "#1E9FFF",
                "color": "white"
            });
        });
        layui.use('table', function() {
            var table = layui.table;
            var $ = layui.$;

            table.render({
                elem: '#demo2',
                height: '150px',
                data: json2,
                cols: [
                    [ //表头
                        {
                            field: 'to',
                            title: '基层医疗机构感染性医疗废物(吨)',
                            width: "20%"
                        }, {
                            field: 'ho',
                            title: '基层医疗机构损伤性医疗废物(吨)',
                            width: "20%"
                        }, {
                            field: 'ba',
                            title: '基层医疗机构病理性医疗废物(吨)',
                            width: "20%"

                        }, {
                            field: 'ca',
                            title: '基层医疗机构药物性医疗废物(吨)',
                            width: "20%"

                        }, {
                            field: 'da',
                            title: '基层医疗机构化学性医疗废物(吨)',
                            width: "20%"

                        }


                    ]
                ],
                skin: 'row', //表格风格				
                even: true,

            });
            $("table thead tr").css({
                "background": "#1E9FFF",
                "color": "white"
            });
        });
        layui.use('table', function() {
            var table = layui.table;
            var $ = layui.$;

            table.render({
                elem: '#demo',
                height: '150px',
                data: json,
                cols: [
                    [ //表头
                        {
                            field: 'to',
                            title: '医疗废物总量(吨)',
                            width: "30%"
                        }, {
                            field: 'ho',
                            title: '医院废物总量(吨)',
                            width: "30%"
                        }, {
                            field: 'ba',
                            title: '基层医疗机构废物总量(吨)',
                            width: "30%"

                        }
                        // , {
                        //     title: '下城区',
                        //     width: "7%",
                        //     align: "center"

                        // }, {
                        //     title: '江干区',
                        //     width: "7%",
                        //     align: "center"
                        // }, {
                        //     title: '拱墅区',
                        //     width: "6%",
                        //     align: "center"
                        // }, {
                        //     title: '西湖区',
                        //     width: "6%",
                        //     align: "center"
                        // }, {
                        //     title: '滨江区',
                        //     width: "6%",
                        //     align: "center"
                        // }, {
                        //     title: '萧山区',
                        //     width: "6%",
                        //     align: "center"
                        // }, {
                        //     title: '余杭区',
                        //     width: "6%",
                        //     align: "center"
                        // }, {
                        //     title: '桐庐县',
                        //     width: "6%",
                        //     align: "center"
                        // }, {
                        //     title: '建德市',
                        //     width: "6%",
                        //     align: "center"
                        // }, {
                        //     title: '富阳区',
                        //     width: "6%",
                        //     align: "center"
                        // }, {
                        //     title: '临安区',
                        //     width: "6%",
                        //     align: "center"
                        // }, {
                        //     title: '淳安县',
                        //     width: "6%",
                        //     align: "center"
                        // }

                    ]
                ],
                skin: 'row', //表格风格				
                even: true,

            });




            $("#serch").on('click', function() {
                var tjson = [];
                $.ajax({
                    url: '../../../All/health',
                    type: "post",
                    datatype: "json",
                    data: {
                        startdate: $("#datetime").val().split(" - ")[0],
                        enddate: $("#datetime").val().split(" - ")[1],
                    },
                    beforeSend: function(res) {

                        $("#serch").html('<i class="layui-icon">&#xe63d;</i>加载中');
                    },
                    success: function(res) {
                        tjson = res.data;
                        tjson.push({
                            type: '合计',
                            aweight: tjson[0].aweight + tjson[1].aweight,
                            bweight: tjson[0].bweight + tjson[1].bweight,
                            cweight: tjson[0].cweight + tjson[1].cweight,
                            dweight: tjson[0].dweight + tjson[1].dweight,
                            eweight: tjson[0].eweight + tjson[1].eweight,
                            fweight: tjson[0].fweight + tjson[1].fweight,
                            gweight: tjson[0].gweight + tjson[1].gweight,
                            hweight: tjson[0].hweight + tjson[1].hweight,
                            iweight: tjson[0].iweight + tjson[1].iweight,
                            jweight: tjson[0].jweight + tjson[1].jweight,
                            kweight: tjson[0].kweight + tjson[1].kweight,
                            lweight: tjson[0].lweight + tjson[1].lweight,
                            mweight: tjson[0].mweight + tjson[1].mweight
                        })
                        var colses = [ //表头
                            {
                                field: 'type',
                                title: '机构类型',
                                width: "10%"
                            }, {

                                title: '全市',
                                width: "7%",
                                align: 'center',
                                templet: function(d) {
                                    return (parseFloat(d.aweight) + parseFloat(d.bweight) + parseFloat(d.cweight) + parseFloat(d.dweight) + parseFloat(d.eweight) + parseFloat(d.fweight) + parseFloat(d.gweight) + parseFloat(d.hweight) + parseFloat(d.iweight) + parseFloat(d.jweight) + parseFloat(d.kweight) + parseFloat(d.lweight) + parseFloat(d.mweight)).toFixed(2);
                                }
                            }, {
                                field: 'aweight',
                                title: '上城区',
                                width: "7%",
                                align: "center"


                            }, {
                                field: 'bweight',
                                title: '下城区',
                                width: "7%",
                                align: "center"


                            }, {
                                field: 'cweight',
                                title: '江干区',
                                width: "7%",
                                align: "center"

                            }, {
                                field: 'dweight',
                                title: '拱墅区',
                                width: "6%",
                                align: "center"

                            }, {
                                field: 'eweight',
                                title: '西湖区',
                                width: "6%",
                                align: "center"

                            }, {
                                field: 'fweight',
                                title: '滨江区',
                                width: "6%",
                                align: "center"

                            }, {
                                field: 'gweight',
                                title: '萧山区',
                                width: "6%",
                                align: "center"

                            }, {
                                field: 'hweight',
                                title: '余杭区',
                                width: "6%",
                                align: "center"

                            }, {
                                field: 'iweight',
                                title: '桐庐县',
                                width: "6%",
                                align: "center"

                            }, {
                                field: 'jweight',
                                title: '建德市',
                                width: "6%",
                                align: "center"

                            }, {

                                field: 'kweight',
                                title: '富阳区',
                                width: "6%",
                                align: "center"

                            }, {
                                field: 'lweight',
                                title: '临安区',
                                width: "6%",
                                align: "center"

                            }, {
                                field: 'mweight',
                                title: '淳安县',
                                width: "6%",
                                align: "center"

                            }
                        ];
                        table.reload('demo', {
                            data: tjson, //异步数据接口的额外参数
                            cols: [colses]
                        });
                        $("table thead tr").css({
                            "background": "#1E9FFF",
                            "color": "white"
                        });
                    },
                    complete: function(XMLHttpRequest, textStatus) {

                        $("#serch").html('<i class="layui-icon">&#xe615;</i>按重量统计');
                    },
                });
            });
            $("#serchcollect").on('click', function() {
                var rjson = [];
                $.ajax({
                    url: '../../../All/health',
                    type: "post",
                    datatype: "json",
                    data: {
                        startdate: $("#datetime").val().split(" - ")[0],
                        enddate: $("#datetime").val().split(" - ")[1],
                    },
                    beforeSend: function(res) {

                        $("#serchcollect").html('<i class="layui-icon">&#xe63d;</i>加载中');
                    },
                    success: function(res) {
                        rjson = res.data;
                        rjson.push({
                            type: '合计',
                            atotal: rjson[0].atotal + rjson[1].atotal,
                            btotal: rjson[0].btotal + rjson[1].btotal,
                            ctotal: rjson[0].ctotal + rjson[1].ctotal,
                            dtotal: rjson[0].dtotal + rjson[1].dtotal,
                            etotal: rjson[0].etotal + rjson[1].etotal,
                            ftotal: rjson[0].ftotal + rjson[1].ftotal,
                            gtotal: rjson[0].gtotal + rjson[1].gtotal,
                            htotal: rjson[0].htotal + rjson[1].htotal,
                            itotal: rjson[0].itotal + rjson[1].itotal,
                            jtotal: rjson[0].jtotal + rjson[1].jtotal,
                            ktotal: rjson[0].ktotal + rjson[1].ktotal,
                            ltotal: rjson[0].ltotal + rjson[1].ltotal,
                            mtotal: rjson[0].mtotal + rjson[1].mtotal
                        })
                        var colss = [ //表头
                            {
                                field: 'type',
                                title: '机构类型',
                                width: "10%"
                            }, {

                                title: '全市',
                                width: "7%",
                                align: 'center',
                                templet: function(d) {
                                    return (parseFloat(d.atotal) + parseFloat(d.btotal) + parseFloat(d.ctotal) + parseFloat(d.dtotal) + parseFloat(d.etotal) + parseFloat(d.ftotal) + parseFloat(d.gtotal) + parseFloat(d.htotal) + parseFloat(d.itotal) + parseFloat(d.jtotal) + parseFloat(d.ktotal) + parseFloat(d.ltotal) + parseFloat(d.mtotal));
                                }
                            }, {
                                field: 'atotal',
                                title: '上城区',
                                width: "7%",
                                align: "center"

                            }, {
                                field: 'btotal',
                                title: '下城区',
                                width: "7%",
                                align: "center"

                            }, {
                                field: 'ctotal',
                                title: '江干区',
                                width: "7%",
                                align: "center"

                            }, {
                                field: 'dtotal',
                                title: '拱墅区',
                                width: "6%",
                                align: "center"

                            }, {
                                field: 'etotal',
                                title: '西湖区',
                                width: "6%",
                                align: "center"
                            }, {
                                field: 'ftotal',
                                title: '滨江区',
                                width: "6%",
                                align: "center"
                            }, {
                                field: 'gtotal',
                                title: '萧山区',
                                width: "6%",
                                align: "center"
                            }, {
                                field: 'htotal',
                                title: '余杭区',
                                width: "6%",
                                align: "center"
                            }, {
                                field: 'itotal',
                                title: '桐庐县',
                                width: "6%",
                                align: "center"
                            }, {
                                field: 'jtotal',
                                title: '建德市',
                                width: "6%",
                                align: "center"
                            }, {

                                field: 'ktotal',
                                title: '富阳区',
                                width: "6%",
                                align: "center"
                            }, {
                                field: 'ltotal',
                                title: '临安区',
                                width: "6%",
                                align: "center"
                            }, {
                                field: 'mtotal',
                                title: '淳安县',
                                width: "6%",
                                align: "center"
                            }
                        ];
                        table.reload('demo', {
                            data: rjson, //异步数据接口的额外参数
                            cols: [colss]
                        });
                        $("table thead tr").css({
                            "background": "#1E9FFF",
                            "color": "white"
                        });
                    },
                    complete: function(XMLHttpRequest, textStatus) {

                        $("#serchcollect").html('<i class="layui-icon">&#xe615;</i>按收集量统计');
                    },
                });
            })

            $("table thead tr").css({
                "background": "#1E9FFF",
                "color": "white"
            });

        });
    </script>
</body>

</html>